import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/Home.vue'

// 把这段代码直接粘贴到router/index.js中的Vue.use(VueRouter)之前
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function(location) {
  return originalPush.call(this, location).catch(err => {})
};
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect:'/home'
  },
  {
    path: '/home',
    name: 'home',
    component: HomeView
  },
  {
    path: '/myyinyue',
    name: 'myyinyue',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "myyinyue" */ '../views/myYinyue.vue')
  },
  {
    path: '/phangbang',
    name: 'phangbang',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "phangbang" */ '../views/pHangbang.vue')
  },
  {
    path: '/gedan',
    name: 'gedan',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "gedan" */ '../views/Gedan.vue')
  },
  {
    path: '/diantai',
    name: 'diantai',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "diantai" */ '../views/Diantai.vue')
  },
  {
    path: '/geshou',
    name: 'geshou',
    redirect:'/geshou/geszti',
    component: () => import(/* webpackChunkName: "geshou" */ '../views/Geshou.vue'),
    children:[
      {
        path: 'geszti',
        name: 'geszti',
        component: () => import('@/components/geshou/GesZuti.vue'),
      },
      {
        path: 'gesdqges',
        name: 'gesdqges',
        component: () => import('@/components/geshou/GesDquges.vue'),
      },
      {
        path: 'gesruzges',
        name: 'gesruzges',
        component: () => import('@/components/geshou/GesRuzges.vue'),
      },
    ]
  },
  {
    path: '/xindie',
    name: 'xindie',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "xindie" */ '../views/Xindie.vue')
  },
  {
    path: "/sousuo",
    name: 'sousuo',
    component: () => import("../components/sousuo/index.vue")
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
